<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <div class="input-group">
            <label>firstName:</label>
            <input type="text" v-model="firstName">
            <span>{{firstName}}</span>
        </div>
        <div class="input-group">
            <label>lastName:</label>
            <input type="text" v-model="lastName">
            <span>{{lastName}}</span>
        </div>
        <div>
            <label>fullName:</label>
            <input type="text" v-model="fullName">
            <span>{{fullName}}</span>
        </div>
    </div>
</body>
<script>
    var vm = new Vue({
        el:"#app",
        data:{
            firstName:"",
            lastName:"",
        },
        computed:{
            // fullName:function(){
            //     return this.firstName + (this.lastName ? " " + this.lastName: "")
            // }

            fullName:{
                get:function(){
                    return this.firstName + (this.lastName ? " " + this.lastName: "")
                },
                set(val){
                    console.log(11111,val);
                    var list = val.split(" ");
                    this.firstName = list[0];
                    this.lastName = list[1]||"";
                }
            }
        },
        methods: {
            changeHandler(){
                console.log(this.isChecked);
            },
            clickHandler(e){
                // console.log(e.target.checked);  // 通过元素本身获取
                console.log(this.isChecked);  // 通过数据获取(change触发才会变,此时获取的是改变之前的数据)
            }
        },
    })


</script>
</html>